<%@page import="bean.VisitDTO"%>
<%@page import="bean.VisitVo"%>
<%@page import="java.util.ArrayList"%>

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>방명록</title>
<link rel='styleSheet' href="VisitMain.css"/>
<script src='../js/VisitMain.js'></script>
</head>
<body>
<jsp:useBean id="vo" class="bean.VisitVo" scope="page"/>
<jsp:setProperty property="*" name="vo"/>    <!-- vo와 넘어온name의 변수명이같아야지만 setter에 넘겨준다.-->
<%
VisitDTO dto=new VisitDTO();
dto.setVo(vo);
boolean b=true;

if(request.getParameter("t")!=null){
	if(request.getParameter("t").equals("1")){
		b	 = dto.visitWrite();
	}
}


ArrayList<VisitVo> al = dto.select();%>
	<form name='frm' method='post' action='guest_main.jsp?inPage=./visitMain.jsp'>
		<div id="top">
		</div>
		<div id="writeBox">
			<textarea id ='writeTextarea' name='content'> </textarea>
			<div id="writeBtnDiv">
				<input type='button' value='글쓰기' id='writeBtn' onclick='input();' /><br/>
			</div>
		</div>


<form name='visit_list_frm' method="post" action="guest_main.jsp?inpage=./visitMain.jsp">
<input type='text' name='find' value = '<%=vo.getFind()%>'>
<input type='submit' value= '검색'>
</form>
<%if(b){
%>
		<br/><br/><br/>
<%for(int i=0; i<al.size(); i++){
	VisitVo v = al.get(i);	
 %> 
		<div class="visitMainBox">
			<div class="viewBox">
			<div class="viewBox_bar"> <!-- 글쓴이, 날짜 나오는곳 -->
				<label class=viewBox_bar_mid>아이디 : <%=v.getMid() %></label> <!-- 글쓴이 -->
				
				<label class=viewBox_bar_wdate><%=v.getVdate() %></label> <!-- 게시 날짜 -->
			</div>
			<%
			int s=0;	
			if( request.getParameter("moveModify")!=null){
				s = Integer.parseInt(request.getParameter("moveModify"));
			}
			if(s==v.getVno()){
				%>
				<textarea class = 'modifyContent2' id='modifyContent2' ><%=v.getContent() %></textarea>
					<div class = "modiDeleBtn">
						<input type='button' value='확인' onclick='modiChoice(<%=v.getVno()%>);'/>
					</div>
			<%} else {
			%>
						
			<textarea class = 'modifyContent' name='modifyContent' disabled="disabled"><%=v.getContent()%>	</textarea>
				<div class = "modiDeleBtn">
				<input type='button' value='수정' onclick='modiOpen(<%= v.getVno()%>);' />
				<input type='button' value='삭제' onclick='deleteChoice(<%=v.getVno() %>);' /><br/>
			</div>
			<%  }		 %>
				<br/>
			
				<a>댓글갯수(1)</a><br/>
			</div>
			<div class="repleBox">
				
				<div class= "repleWriteBox">
					<input type='text' id='repleTextBox' name='rcontent'/>

					<input type='button' value='댓글달기'  onclick=' ' style='height: 30px;'/><br/>
				</div>

				<div class="repleView">
					<textarea></textarea>
					<input type='button' value='X'  />
				</div>
			</div>
		</div>
		<br/><br/><br/><br/>
		<%} } %>
	</form>
	<form name='hiddenFrm' method='post'>
		<input type='hidden' name='content' />
		<input type='hidden' name='vno'/>
	</form>
		<div id = 'list_page'>
	<%if(dto.getNowBlock()>=1) {%>
	<a href='#' onclick='goPage(1)'>맨첨</a>
	<%} %>
	<a href='#' onclick='goPage(<%=dto.getStartPage()-1 %>)'>이전</a>
	
	<% 
	int i=0;
	for( i=dto.getStartPage(); i<=dto.getEndPage(); i++){%>
			<a href='#' onclick = 'goPage( <%=i%> )'><%=i %></a>
	 <%}%>
	 <%if(dto.getNowBlock()<dto.getTotBlock()) {%>
	 <a href='#' onclick='goPage(<%=i%>)' >다음</a>
	 <%} %>
	  <a href='#' onclick=' goPage(<%=dto.getTotPage()%>)'>맨끝</a>
	</div>
<script>Init();</script>



</body>
</html>

